<!-- getting the current URI to set the currentController, currenView, projectId-->
<%
String ur="${request.forwardURI}"
def cont=Inter.outSplit(ur,'cont')
def vie=Inter.outSplit(ur,'vie')
def proID=Inter.outSplit(ur,'proID')

def picture = "merp_logo_small.png"
def link = "http://www.hetmedia.se/megasoft/"
def access = session.access
access.refresh()

if(!access.hasDevAuth()){
  picture = access.container.picture
  link = access.container.link
}
%>
<html>
    <head>
        <title><g:layoutTitle default="MegaSoft" /></title>
        <link rel="stylesheet" href="${resource(dir:'css',file:'main.css')}" />
        <link rel="shortcut icon" href="${resource(dir:'images',file:'favicon.ico')}" type="image/x-icon" />
        <g:layoutHead />
        <g:javascript src="jquery.js" />
        <g:javascript library="application" />
        <g:javascript src="detectClose.js" />
    </head>
    <body>
      <div id="spinner" class="spinner" style="display:none;">
          <img src="${resource(dir:'images',file:'spinner.gif')}" alt="Spinner" />
      </div>
      <div class="logo">
       <a href="http://www.hetmedia.se/megasoft/" target="_blank">
         <img src="${resource(dir:'images',file:picture)}" style="float:left; margin-left:10px; border:0" alt="IDA" />
       </a>
        <!--the language button with flag and so on-->
        <div align="right">
          <g:btnLanguage language="${session.language}"  currentController="${cont}" currentView="${vie}" idProject="${proID}"></g:btnLanguage>
          <g:btnMode mode="${session.mode}" currentView="${vie}" currentController="${cont}"></g:btnMode>
        </div>
      </div>
      <div class="nav" style="padding:0px">
        <table style="border:none; margin:0px;">
          <tr>
            <td>
              <div>
                  <span class="menuButton"><a class="home" href="${resource(dir:'')}">${Inter.printOut('Home',session.language)}</a></span>
                  
                  <g:if test="${session?.container}">
                    <g:if test="${Container.get(session?.container)?.hasTab('Employee')}">
                       <span class="menuButton"><g:link class="listEmployee" controller="employee" action="list">${Inter.printOut('Employees',session.language)}</g:link></span>
                    </g:if>
                    <g:if test="${session?.container && Container.get(session?.container)?.hasTab('Project')}">
                       <span class="menuButton"><g:link class="listProject" controller="project" action="list">${Inter.printOut('Projects',session.language)}</g:link></span>
                    </g:if>
                    <g:if test="${session?.container && Container.get(session?.container)?.hasTab('Course')}">
                    <span class="menuButton"><g:link class="listCourses" controller="course" action="list">${Inter.printOut('Courses',session.language)}</g:link></span>
                    </g:if>
                    <g:if test="${session?.container && Container.get(session?.container)?.hasTab('Admin')}">
                      <span class="menuButton"><g:link class="adminPage" controller="admin" action="show">Administration</g:link></span>
                    </g:if>
                  </g:if>
                  <g:else>
                    <span class="menuButton"><g:link class="listEmployee" controller="employee" action="list">${Inter.printOut('Employees',session.language)}</g:link></span>
                    <span class="menuButton"><g:link class="listProject" controller="project" action="list">${Inter.printOut('Projects',session.language)}</g:link></span>
                    <span class="menuButton"><g:link class="listCourses" controller="course" action="list">${Inter.printOut('Courses',session.language)}</g:link></span>
                    <span class="menuButton"><g:link class="adminPage" controller="admin" action="show">Administration</g:link></span>
                  </g:else>
                </div>
            </td>
            <td>
              <div align="right">
                <span>
                   <g:if test="${session?.access}">
                      Connected as ${session?.access?.userName} |
                      <span class="menuButton"><g:link class="logout" controller="access" onclick="return confirmSave(${session.modified});" action="logout">${Inter.printOut('Log Out',session.language)}</g:link></span>
                    </g:if>
                    <g:else>
                      Not connected |  <span class="menuButton"><g:link class="login" controller="access" action="login">Log In</g:link></span>
                   </g:else>
                </span>
              </div>
            </td>
          </tr>
        </table>
      </div>
      <g:layoutBody />
    </body>
</html>
